<?php
/**
 * 这是视图共享文件中需要传到Capp\Http\ViewComposers)admincomposer的数据
 */
namespace App\Libs;

use App\Admin;
use App\RoleAdmin;
use App\Role;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Auth;

class CommonUtils {
    public $prole = null;//管理员角色
    public $menu = null;//菜单对象

    /**
     * 构造函数
     */
    public function __construct(Request $request)
    {
        $this -> init($request);
    }

    /**
     * 初始化函数
     */

    private function init(Request $request)
    {
        $this -> getProle($request);
        $this -> getMenu($request);
    }

    //获取菜单
    public function getMenu(Request $request)
    {

    }

    //获取管理员的角色
    public function getProle(Request $request)
    {
        //获取当前用户的角色
        $admin_id =  Auth::guard('admin')->id();
        $role_id = RoleAdmin::where('admin_id',$admin_id)->value('role_id');
        $prole = Role::where('id',$role_id)->value('description');
        $this -> prole = $prole;
    }
}